﻿using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Linq;
using System.Text;
using Yammu.Core;

namespace Yammu.Core.VirtualFileSystem
{
    /// <summary>
    /// Types implementing this interface provide access to a file system like LocalFiles, Dropbox, Ftp etc.
    /// This interface abstracts this access mechanism.
    /// </summary>
    [InheritedExport(typeof(IVFSProvider))]
    public interface IVFSProvider
    {
        /// <summary>
        /// Initializes the provider with the specified configuration and credentials
        /// </summary>
        /// <param name="config">The config.</param>
        /// <param name="credentials">The credentials.</param>
        void Initialize(IVFSProviderConfiguration config,IVFSProviderCredentials credentials);

        /// <summary>
        /// Combines two virtual paths
        /// </summary>
        /// <param name="basePath">The base path.</param>
        /// <param name="relativePath">The relative path.</param>
        /// <returns></returns>
        string CombineVirtualPaths(string basePath, string relativePath);

        /// <summary>
        /// Returns true if the directory exists otherwise false.
        /// </summary>
        /// <param name="virtualDir">The virtual dir.</param>
        /// <returns></returns>
        bool DirectoryExists(string virtualDir);

        /// <summary>
        /// Returns true if the file exists otherwise false
        /// </summary>
        /// <param name="virtualPath"></param>
        /// <returns></returns>
        bool FileExists(string virtualPath);

        /// <summary>
        /// <see cref="IVFSItem.VirtualPath"/>
        /// </summary>
        /// <param name="virtualDir"></param>
        /// <returns></returns>
        IVFSItem GetDirectory(string virtualDir);
        
        IVFSItem GetFile(string virtualPath);

        /// <summary>
        /// Returns the hash for the given file. Note if the provider does not support hashing, this may return 
        /// true.
        /// </summary>
        /// <param name="virtualPath"></param>
        /// <returns></returns>
        string GetFileHash(string virtualPath);
        
        /// <summary>
        /// Returns the root of the given virtual item. If the entry is null then the root of the file system is provided.
        /// </summary>
        /// <param name="entry"></param>
        /// <returns></returns>
        IVFSItem GetRoot(IVFSItem entry);
        
        IVFSProviderCredentials Credentials {  get;   }
        
        IVFSProviderConfiguration Config { get;  }
    
    }
}
